﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace VetumaForSP2010.Configuration
{
    /// <summary>
    /// Vetuma configurations, located to sharepoint web application's web.config
    /// </summary>
    public class VetumaConfig : ConfigurationElement
    {
        [ConfigurationProperty("SharedSecretId", IsRequired = true)]
        public string SharedSecretId
        {
            get
            {
                if (this["SharedSecretId"] != null)
                {
                    return this["SharedSecretId"].ToString();
                }
                else
                {
                    throw new NullReferenceException("SharedSecretId property missing from web.config.");
                }
            }
        }

        [ConfigurationProperty("SharedSecret", IsRequired = true)]
        public string SharedSecret
        {
            get
            {
                if (this["SharedSecret"] != null)
                {
                    return this["SharedSecret"].ToString();
                }
                else
                {
                    throw new NullReferenceException("SharedSecret property missing from web.config.");
                }
            }
        }

        [ConfigurationProperty("ConfigurationId", IsRequired = true)]
        public string ConfigurationId
        {
            get
            {
                if (this["ConfigurationId"] != null)
                {
                    return this["ConfigurationId"].ToString();
                }
                else
                {
                    throw new NullReferenceException("ConfigurationId property missing from web.config.");
                }
            }
        }

        /// <summary>
        /// Url of Vetuma service
        /// </summary>
        [ConfigurationProperty("PostUrl", IsRequired = true)]
        public string PostUrl
        {
            get
            {
                if (this["PostUrl"] != null)
                {
                    return this["PostUrl"].ToString();
                }
                else
                {
                    throw new NullReferenceException("PostUrl property missing from web.config.");
                }
            }
        }

        /// <summary>
        /// Names of the methods that is supported in customer's Vetuma contract
        /// </summary>
        [ConfigurationProperty("SupportedAuthenticationMethods", IsRequired = true)]
        public string AuthenticationMethods
        {
            get
            {
                if (this["SupportedAuthenticationMethods"] != null)
                {
                    return this["SupportedAuthenticationMethods"].ToString();
                }
                else
                {
                    throw new NullReferenceException("SupportedAuthenticationMethods property missing from web.config.");
                }
            }
        }

        [ConfigurationProperty("ApplicationId", IsRequired = true)]
        public string ApplicationId
        {
            get
            {
                if (this["ApplicationId"] != null)
                {
                    return this["ApplicationId"].ToString();
                }
                else
                {
                    throw new NullReferenceException("ApplicationId property missing from web.config.");
                }
            }
        }

        public VetumaConfig() { }
    }
}
